import request from '@/config/axios'

/** 模型信息 */
export interface OxMode {
  id: number // 模型ID
  modeName: string // 模型名称
  modeParents: string // 父类模型
  modePath: string // 模型路径
  projectId: number // 项目id
  status: number // 模型状态：0-训练中，1-已完成，2-失败
  accuracy: number // 模型准确率（0-1之间的小数）
}

// 模型 API
export const OxModeApi = {
  // 查询模型分页
  getOxModePage: async (params: any) => {
    return await request.get({ url: `/happy-ox-core/ox-mode/page`, params })
  },

  // 查询模型详情
  getOxMode: async (id: number) => {
    return await request.get({ url: `/happy-ox-core/ox-mode/get?id=` + id })
  },

  // 新增模型
  createOxMode: async (data: OxMode) => {
    return await request.post({ url: `/happy-ox-core/ox-mode/create`, data })
  },

  // 修改模型
  updateOxMode: async (data: OxMode) => {
    return await request.put({ url: `/happy-ox-core/ox-mode/update`, data })
  },

  // 删除模型
  deleteOxMode: async (id: number) => {
    return await request.delete({ url: `/happy-ox-core/ox-mode/delete?id=` + id })
  },

  /** 批量删除模型 */
  deleteOxModeList: async (ids: number[]) => {
    return await request.delete({ url: `/happy-ox-core/ox-mode/delete-list?ids=${ids.join(',')}` })
  },

  // 导出模型 Excel
  exportOxMode: async (params) => {
    return await request.download({ url: `/happy-ox-core/ox-mode/export-excel`, params })
  },
  predictDog: async (params: any) => {
    return await request.post({
      url:
        `/happy-ox-core/ox-mode/predictDog?imagePath=` +
        params.imagePath +
        '&modelId=' +
        params.modelId
    })
  }
}
